package com.ss.tmall.service.impl;

import com.ss.tmall.mapper.CategoryMapper;
import com.ss.tmall.pojo.Category;
import com.ss.tmall.pojo.CategoryExample;
import com.ss.tmall.service.CategoryService;
import com.ss.tmall.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: ShengShuai
 * @Description:
 * @Date: Created in 下午 23:57  2017/12/22 0022
 * @Modified By:
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public List<Category> list() {
        CategoryExample categoryExample=new CategoryExample();
        categoryExample.setOrderByClause("id desc");
        return categoryMapper.selectByExample(categoryExample);
    }


    @Override
    public void add(Category category) {
        categoryMapper.insert(category);
    }

    @Override
    public void delete(Integer id) {
        categoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Category get( Integer id) {
        return categoryMapper.selectByPrimaryKey(id);
    }
    @Override
    public  void  update(Category category){
     categoryMapper.updateByPrimaryKeySelective(category);
    }
}
